/*
 * ServerAdminOverviewRefresher.java
 *
 * Created on 12. Juni 2007, 17:05
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package DieSiedler;

import java.rmi.RemoteException;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;

/**
 *
 * @author mannholi
 */
public class ServerAdminOverviewRefresher extends Thread{
    
    /** Creates a new instance of ServerAdminOverviewRefresher */
    private boolean run=true;
    private SpielLogik logik;
    private long refreshTime;
    private ServerAdminGraphicalOverview overview;
    private Server server;
    private LinkedList list;
 
    public ServerAdminOverviewRefresher(Server server, ServerAdminGraphicalOverview overview,long refreshTime) {
        this.logik=logik;
        
        this.refreshTime=refreshTime;
        this.overview=overview;
        this.server=server;
    }
    
    public void run(){
        
        while(run){
            try {
               
               this.sleep(refreshTime);
             
               Iterator<PlayerIdentification> iterator = server.getPlayers().iterator();              
               PlayerIdentification pl;
               while(iterator.hasNext()){
                    pl=iterator.next();
                    overview.update(pl.getPlayerID());
               }
               overview.update();
               overview.updateState();
                
            }catch (RemoteException ex) {
                ex.printStackTrace();
            } 
            catch (InterruptedException ex) {
                ex.printStackTrace();
            }
        }
        run=false;
    }
    
    public void destroyThread(){
        run=false;
    }
    
   
    
}
